

-- a jitter blur filter implemented in lua





count  = 8   -- number of samplings

amount = 32   -- amount of spread



edge_duplicate=1

local x,y

--math.randomseed(1)

for y = 0, height-1 do

    for x = 0, width-1 do

       local rsum,gsum,bsum,asum=0,0,0,0



       for n=1, count do

          local nx,ny,r,g,b,a

          nx=x+(math.random()-0.5)*amount

          ny=y+(math.random()-0.5)*amount

          r,g,b,a= get_rgba(nx,ny)

          rsum,gsum,bsum,asum=rsum+r,gsum+g,bsum+b,asum+a

       end



       set_rgba (x,y, rsum/count,gsum/count,bsum/count,asum/count)

    end

    progress(y/height)

end

